package com.google.gson;

import com.google.gson.internal.bind.TypeAdapter;
import com.google.gson.internal.bind.TypeAdapter.Factory;
import com.google.gson.internal.bind.a;
import com.google.gson.internal.bind.b;
import com.google.gson.internal.bind.c;
import com.google.gson.internal.bind.d;
import com.google.gson.internal.bind.g;
import com.google.gson.internal.bind.h;
import com.google.gson.internal.bind.j;
import com.google.gson.internal.bind.l;
import com.google.gson.internal.bind.m;
import com.google.gson.internal.bind.o;
import com.google.gson.internal.bind.q;
import com.google.gson.internal.bind.t;
import com.google.gson.internal.bind.w;
import com.google.gson.internal.bind.y;
import com.google.gson.internal.i;
import com.google.gson.internal.k;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public final class f {
    static final i a = new i().a();
    static final a b = new a();
    static final z c = new z(true);
    static final w d = new w(128, 8);
    static final e e = new y(new h());
    private static final ExclusionStrategy f = a();
    private final ExclusionStrategy g;
    private final ExclusionStrategy h;
    private final com.google.gson.internal.f i;
    private final i j;
    private final i k;
    private final boolean l;
    private final boolean m;
    private final boolean n;
    private final boolean o;
    private final l p;

    public f() {
        this(f, f, e, a, false, a, a, false, false, true, false, false, r.DEFAULT, Collections.emptyList());
    }

    f(ExclusionStrategy exclusionStrategy, ExclusionStrategy exclusionStrategy2, final e eVar, i iVar, boolean z, i iVar2, i iVar3, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, r rVar, List list) {
        this.g = exclusionStrategy;
        this.h = exclusionStrategy2;
        this.i = new com.google.gson.internal.f(iVar);
        this.l = z;
        this.j = iVar2;
        this.k = iVar3;
        this.n = z3;
        this.m = z4;
        this.o = z5;
        Factory anonymousClass1 = new q(this, this.i) {
            final /* synthetic */ f b;

            public String a(Class cls, Field field, Type type) {
                return eVar.a(new d(cls, field));
            }

            public boolean b(Class cls, Field field, Type type) {
                ExclusionStrategy a = this.b.h;
                return (a.shouldSkipClass(field.getType()) || a.shouldSkipField(new d(cls, field))) ? false : true;
            }

            public boolean c(Class cls, Field field, Type type) {
                ExclusionStrategy b = this.b.g;
                return (b.shouldSkipClass(field.getType()) || b.shouldSkipField(new d(cls, field))) ? false : true;
            }
        };
        m a = new m().a().a(y.w).a(y.k).a(y.e).a(y.g).a(y.i).a(y.a(Long.TYPE, Long.class, a(rVar))).a(y.a(Double.TYPE, Double.class, a(z6))).a(y.a(Float.TYPE, Float.class, b(z6))).a(new g(exclusionStrategy2, exclusionStrategy)).a(y.s).a(y.u).a(y.y).a(y.A).a(BigDecimal.class, new b()).a(BigInteger.class, new c()).a(y.P).a(o.a);
        for (Factory a2 : list) {
            a.a(a2);
        }
        a.a(new g(this, iVar2, iVar3)).a(new d(this.i)).a(y.C).a(y.E).a(y.I).a(y.N).a(y.G).a(y.b).a(com.google.gson.internal.bind.f.a).a(y.L).a(w.a).a(t.a).a(y.J).a(new j(this.i, z2)).a(a.a).a(y.Q).a(anonymousClass1);
        this.p = a.b();
    }

    private static ExclusionStrategy a() {
        Collection linkedList = new LinkedList();
        linkedList.add(b);
        linkedList.add(c);
        linkedList.add(d);
        return new c(linkedList);
    }

    private com.google.gson.b.d a(Writer writer) throws IOException {
        if (this.n) {
            writer.write(")]}'\n");
        }
        com.google.gson.b.d dVar = new com.google.gson.b.d(writer);
        if (this.o) {
            dVar.c("  ");
        }
        dVar.d(this.l);
        return dVar;
    }

    private TypeAdapter a(r rVar) {
        return rVar == r.DEFAULT ? y.l : new TypeAdapter(this) {
            final /* synthetic */ f a;

            {
                this.a = r1;
            }

            public Number a(com.google.gson.b.a aVar) throws IOException {
                if (aVar.f() != com.google.gson.b.c.NULL) {
                    return Long.valueOf(aVar.l());
                }
                aVar.j();
                return null;
            }

            public void a(com.google.gson.b.d dVar, Number number) throws IOException {
                if (number == null) {
                    dVar.f();
                } else {
                    dVar.b(number.toString());
                }
            }

            public /* synthetic */ Object b(com.google.gson.b.a aVar) throws IOException {
                return a(aVar);
            }
        };
    }

    private TypeAdapter a(boolean z) {
        return z ? y.p : new TypeAdapter(this) {
            final /* synthetic */ f a;

            {
                this.a = r1;
            }

            public Double a(com.google.gson.b.a aVar) throws IOException {
                if (aVar.f() != com.google.gson.b.c.NULL) {
                    return Double.valueOf(aVar.k());
                }
                aVar.j();
                return null;
            }

            public void a(com.google.gson.b.d dVar, Number number) throws IOException {
                if (number == null) {
                    dVar.f();
                    return;
                }
                this.a.a(number.doubleValue());
                dVar.a(number);
            }

            public /* synthetic */ Object b(com.google.gson.b.a aVar) throws IOException {
                return a(aVar);
            }
        };
    }

    private void a(double d) {
        if (Double.isNaN(d) || Double.isInfinite(d)) {
            throw new IllegalArgumentException(d + " is not a valid double value as per JSON specification. To override this" + " behavior, use GsonBuilder.serializeSpecialDoubleValues() method.");
        }
    }

    private static void a(Object obj, com.google.gson.b.a aVar) {
        if (obj != null) {
            try {
                if (aVar.f() != com.google.gson.b.c.END_DOCUMENT) {
                    throw new k("JSON document was not fully consumed.");
                }
            } catch (Throwable e) {
                throw new q(e);
            } catch (Throwable e2) {
                throw new k(e2);
            }
        }
    }

    private TypeAdapter b(boolean z) {
        return z ? y.n : new TypeAdapter(this) {
            final /* synthetic */ f a;

            {
                this.a = r1;
            }

            public Float a(com.google.gson.b.a aVar) throws IOException {
                if (aVar.f() != com.google.gson.b.c.NULL) {
                    return Float.valueOf((float) aVar.k());
                }
                aVar.j();
                return null;
            }

            public void a(com.google.gson.b.d dVar, Number number) throws IOException {
                if (number == null) {
                    dVar.f();
                    return;
                }
                this.a.a((double) number.floatValue());
                dVar.a(number);
            }

            public /* synthetic */ Object b(com.google.gson.b.a aVar) throws IOException {
                return a(aVar);
            }
        };
    }

    public j a(Object obj) {
        return obj == null ? l.a : a(obj, obj.getClass());
    }

    public j a(Object obj, Type type) {
        com.google.gson.b.d iVar = new com.google.gson.internal.bind.i();
        a(obj, type, iVar);
        return iVar.a();
    }

    public Object a(com.google.gson.b.a aVar, Type type) throws k, q {
        boolean z = true;
        boolean o = aVar.o();
        aVar.a(true);
        try {
            aVar.f();
            z = false;
            Object b = this.p.a(com.google.gson.a.a.a(type)).b(aVar);
            aVar.a(o);
            return b;
        } catch (Throwable e) {
            if (z) {
                aVar.a(o);
                return null;
            }
            throw new q(e);
        } catch (Throwable e2) {
            throw new q(e2);
        } catch (Throwable e22) {
            throw new q(e22);
        } catch (Throwable th) {
            aVar.a(o);
        }
    }

    public Object a(j jVar, Class cls) throws q {
        return com.google.gson.internal.j.a(cls).cast(a(jVar, (Type) cls));
    }

    public Object a(j jVar, Type type) throws q {
        return jVar == null ? null : a(new h(jVar), type);
    }

    public Object a(Reader reader, Type type) throws k, q {
        com.google.gson.b.a aVar = new com.google.gson.b.a(reader);
        Object a = a(aVar, type);
        a(a, aVar);
        return a;
    }

    public Object a(String str, Class cls) throws q {
        return com.google.gson.internal.j.a(cls).cast(a(str, (Type) cls));
    }

    public Object a(String str, Type type) throws q {
        return str == null ? null : a(new StringReader(str), type);
    }

    public String a(j jVar) {
        Appendable stringWriter = new StringWriter();
        a(jVar, stringWriter);
        return stringWriter.toString();
    }

    public void a(j jVar, com.google.gson.b.d dVar) throws k {
        boolean g = dVar.g();
        dVar.b(true);
        boolean h = dVar.h();
        dVar.c(this.m);
        boolean i = dVar.i();
        dVar.d(this.l);
        try {
            k.a(jVar, dVar);
            dVar.b(g);
            dVar.c(h);
            dVar.d(i);
        } catch (Throwable e) {
            throw new k(e);
        } catch (Throwable th) {
            dVar.b(g);
            dVar.c(h);
            dVar.d(i);
        }
    }

    public void a(j jVar, Appendable appendable) throws k {
        try {
            a(jVar, a(k.a(appendable)));
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }

    public void a(Object obj, Type type, com.google.gson.b.d dVar) throws k {
        TypeAdapter a = this.p.a(com.google.gson.a.a.a(type));
        boolean g = dVar.g();
        dVar.b(true);
        boolean h = dVar.h();
        dVar.c(this.m);
        boolean i = dVar.i();
        dVar.d(this.l);
        try {
            a.a(dVar, obj);
            dVar.b(g);
            dVar.c(h);
            dVar.d(i);
        } catch (Throwable e) {
            throw new k(e);
        } catch (Throwable th) {
            dVar.b(g);
            dVar.c(h);
            dVar.d(i);
        }
    }

    public void a(Object obj, Type type, Appendable appendable) throws k {
        try {
            a(obj, type, a(k.a(appendable)));
        } catch (Throwable e) {
            throw new k(e);
        }
    }

    public String b(Object obj) {
        return obj == null ? a(l.a) : b(obj, obj.getClass());
    }

    public String b(Object obj, Type type) {
        Appendable stringWriter = new StringWriter();
        a(obj, type, stringWriter);
        return stringWriter.toString();
    }

    public String toString() {
        return "{" + "serializeNulls:" + this.l + ",serializers:" + this.j + ",deserializers:" + this.k + ",instanceCreators:" + this.i + "}";
    }
}
